<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/doctrine/BaseFormFilterDoctrine.class.php');

/**
 * Item filter form base class.
 *
 * @package    filters
 * @subpackage Item *
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 11675 2008-09-19 15:21:38Z fabien $
 */
class BaseItemFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_tipo'    => new sfWidgetFormDoctrineChoice(array('model' => 'Tipo', 'add_empty' => true)),
      'id_usuario' => new sfWidgetFormDoctrineChoice(array('model' => 'DadosUsuario', 'add_empty' => true)),
      'nm_item'    => new sfWidgetFormFilterInput(),
      'ds_item'    => new sfWidgetFormFilterInput(),
      'ds_resumo'  => new sfWidgetFormFilterInput(),
      'st_item'    => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'destaque'   => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'pb_item'    => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'vl_item'    => new sfWidgetFormFilterInput(),
      'ds_tags'    => new sfWidgetFormFilterInput(),
      'url'        => new sfWidgetFormFilterInput(),
      'slug'       => new sfWidgetFormFilterInput(),
      'created_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'updated_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
    ));

    $this->setValidators(array(
      'id_tipo'    => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'Tipo', 'column' => 'id_tipo')),
      'id_usuario' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'DadosUsuario', 'column' => 'id_dados_usuario')),
      'nm_item'    => new sfValidatorPass(array('required' => false)),
      'ds_item'    => new sfValidatorPass(array('required' => false)),
      'ds_resumo'  => new sfValidatorPass(array('required' => false)),
      'st_item'    => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'destaque'   => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'pb_item'    => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'vl_item'    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'ds_tags'    => new sfValidatorPass(array('required' => false)),
      'url'        => new sfValidatorPass(array('required' => false)),
      'slug'       => new sfValidatorPass(array('required' => false)),
      'created_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('item_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Item';
  }

  public function getFields()
  {
    return array(
      'id_item'    => 'Number',
      'id_tipo'    => 'ForeignKey',
      'id_usuario' => 'ForeignKey',
      'nm_item'    => 'Text',
      'ds_item'    => 'Text',
      'ds_resumo'  => 'Text',
      'st_item'    => 'Boolean',
      'destaque'   => 'Boolean',
      'pb_item'    => 'Boolean',
      'vl_item'    => 'Number',
      'ds_tags'    => 'Text',
      'url'        => 'Text',
      'slug'       => 'Text',
      'created_at' => 'Date',
      'updated_at' => 'Date',
    );
  }
}